package hao.itheima.controller;


import hao.itheima.entity.JobOption;
import hao.itheima.entity.Result;
import hao.itheima.entity.StudentOption;
import hao.itheima.mapper.StudentMapper;
import hao.itheima.service.ReportService;
import hao.itheima.service.impl.StudentServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@Slf4j
@RestController
@RequestMapping("/report") // 公共映射路径抽取
public class ReportController {


    @Autowired
    private ReportService reportService;
    @Autowired
    private StudentMapper studentMapper;
    @Autowired
    private StudentServiceImpl studentServiceImpl;

    /**
     * 统计员工职位人数
     */
    @GetMapping("/empJobData")
    public Result getEmpJobData() {
        JobOption jobOptions = reportService.getEmpJobData();
        return Result.success(jobOptions);

    }

    /**
     * 统计员工性别信息
     *
     * @return
     */
    @GetMapping("/empGenderData")
    public Result getEmpGenderData() {
        //思路是,封装到一个Map集合中返回
        List<Map<String, Object>> map = reportService.getEmpGenderData();
        return Result.success(map);
    }

    /**
     * 统计学员的学历信息
     *
     * @return
     */
    @GetMapping("/studentDegreeData")
    public Result getStudentDegreeData() {
        //1、将统计结果封装到List集合中返回
        List<Map<String, Object>> map = reportService.getStudentDegreeData();
        //2、将结果进行返回
        return Result.success(map);
    }

    /**
     * 统计每一个班级的人数
     * //涉及表: student
     *
     * @return
     */
    @GetMapping("/studentCountData")
    public Result getStudentCountData() {
        StudentOption studentOption = reportService.getStudentCountData();
        return Result.success(studentOption);
    }
}
